package com.jp.knowledge.util;

import android.view.View;

/**
 * Created by 528787067@qq.com on 2017/2/8.
 */

public class TouchUtils {

    /* 判断事件是否发生在 view 上 */
    public static boolean isEventInView(float x, float y, View view){
        if(view == null)
            return false;
        int[] viewLocation = new int[2];
        view.getLocationOnScreen(viewLocation);
        if(x >= viewLocation[0]
                && x <= viewLocation[0]+view.getWidth()
                && y >= viewLocation[1]
                && y <= viewLocation[1]+view.getHeight())
            return true;
        else
            return false;
    }
}
